n = int(input())
holes = [0]*n
a = 0
b = 2
for i in range(1000):
    holes[a] = 1
    a += b
    a %= n
    b += 1

if min(holes)==1:
    print(0)
else:
    for i,v in enumerate(holes):
        if v==0:
            print(i+1)

